package Chapter08;

import java.util.LinkedList;

/**
 * Created by a on 2017/6/16.
 */
public class Test183 {

    public static void main(String[] args) {
        Stack<String> stack = new Stack<String>();
        stack.push("视频学java");
        stack.push("细说java");
        stack.push("java从入门到放弃");
        while (!stack.empyt()){
            System.out.println(stack.pop() instanceof  String);
        }

    }


}

class Stack<T> {

    private LinkedList<T> linkedList = new LinkedList<T>();
    private int index = 0;
    public void push(T object){
        if (index != linkedList.size()){
            linkedList.addFirst(object);
        }
    }

    public Object pop(){
        if (index != -1){
            return linkedList.removeFirst();
        }
        return null;
    }

    public boolean empyt(){
        if (index == 0){
            return true;
        }else {
            return false;
        }
    }
}
